<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<br>
<form class="layui-form" action="" id="form1">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">父功能菜单</label>
            <div class="layui-input-inline">
                <select name="parent_id"  lay-search="">
                    <option value="">选择父菜单</option>
                    <option value="0">根节点</option>
                    <option th:each="menu : ${parentMenus}" th:value="${menu.id}" th:text="${menu.name}"></option>
                </select>
            </div>
        </div>
    </div>



    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">访问路径</label>
            <div class="layui-input-inline">
                <input lay-verify="required" type="text" name="path"  autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">权限标识</label>
            <div class="layui-input-inline">
                <select name="authorization_flag" lay-search="">
                    <option value="READ">READ</option>
                    <option value="ADD">ADD</option>
                    <option value="EDIT">EDIT</option>
                    <option value="SAVE">SAVE</option>
                    <option value="DELETE">DELETE</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">是否是菜单</label>
            <div class="layui-input-inline">
                <select name="is_menu"  lay-search="">
                    <option th:value="1">是</option>
                    <option th:value="0">否</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="button" onclick="doSave();" class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>


</form>


<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var $,layer;
    layui.use(['form' , 'laydate'], function(){
        $=layui.jquery;
        layer = layui.layer;
        var  laydate = layui.laydate;
        laydate.render({
            elem: '#order_date'
        });
    });
    
    function doSave() {
        var requestData = $("#form1").serialize();
        $.post("/permission/save",requestData,function (responseData) {
            console.log(responseData);
            if(responseData.success ==1){
                layer.alert("保存成功",{yes:function () {
                        parent.layer.closeAll();
                    }});
            }else{
                layer.alert("保存失败",{yes:function () {
                        parent.layer.closeAll();
                    }});
            }

        })
    }
    
</script>

</body>
</html>